<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
		<title>店铺首页</title>
		<link rel="stylesheet" href="css/base.css" />
		<link rel="stylesheet" href="css/all.css" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<link rel="stylesheet" href="css/store-shelves.css" />
		<script src="js/url.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<div>
			<div class="head">
				<span href="javascript:;" onclick="go()">
        <i class="iconfont icon-iconfontjiantou1"></i></span>
				<h1 class="titles">店铺首页</h1>
			</div>
			<div class="middle-one">
				<div class="shop">
					<div class="row">
						<div onclick="location.href='./shop-modify.html'" class="logo">
							<!-- <img src="img/500473822.png" alt="" id="dianPuTuPian"> -->
							<img src="" alt="" id="dianPuTuPian">
						</div>
						<div onclick="location.href='./shop-modify.html'" class="firm">
							<span id="dianPuName"></span>
						</div>
						<div onclick="location.href='./chat.html'" class="message">
							<i class="iconfont icon-xiaoxi"></i>
							<span>消息</span>
						</div>
						<div onclick="location.href='./order-income.html'" class="order">
							<i class="iconfont icon-dingdan"></i>
							<span>订单收入</span>
						</div>
					</div>
					<p class="intro" id="dianPuJianjie"></p>
				</div>
				<div class="sold-out">
					<div class="sold flex">
						<div onclick="shopInfo(0,'solds')" class="solds" id="solds">
							<span>出售中</span>
						</div>
						<div onclick="shopInfo(1,'sell')" class="sell" id="sell">
							<span>已下架</span>
						</div>
					</div>
				</div>
					<div class="refer">
					<div id="shopping-info">
						<!--<div onclick="location.href='./edit-commodity.html'" class="introduce row">
							<div class="picture">
								<img src="img/shangpin.png" alt="">
							</div>
							<div class="design">
								<p>灯具</p>
								<p>￥150.00</p>
								<span>总销量 0</span><span>30日成交额 0.00</span>
								<span>库存 69</span><span>添加 2018/08/30</span>
							</div>
							<div class="tag">
								<i class="iconfont icon-youjiantou"></i>
							</div>
						</div>
						<div class="popular">
							<div class="gener">
								<i class="iconfont icon-fenxiang"></i>
								<span>推广</span>
							</div>
							<div class="geners">
								<i class="iconfont icon-icon_share"></i>
								<span>分享</span>
							</div>
						</div>
					</div>
					<div class="refer">
						<div onclick="location.href='./edit-commodity.html'" class="introduce row">
							<div class="picture">
								<img src="img/shangpin.png" alt="">
							</div>
							<div class="design">
								<p>灯具</p>
								<p>￥150.00</p>
								<span>总销量 0</span><span>30日成交额 0.00</span>
								<span>库存 69</span><span>添加 2018/08/30</span>
							</div>
							<div class="tag">
								<i class="iconfont icon-youjiantou"></i>
							</div>
						</div>
						<div class="popular">
							<div class="gener">
								<i class="iconfont icon-fenxiang"></i>
								<span>推广</span>
							</div>
							<div class="geners">
								<i class="iconfont icon-icon_share"></i>
								<span>分享</span>
							</div>
						</div>-->
					</div>
				</div>
			</div>
			<div class="footer">
				<ul class="row">
					<li onclick="location.href='./add-goods.html'" class="new-product">
						<i class="iconfont icon-tianjia"></i>
						<span>发布新品</span>
					</li>
					<li onclick="location.href='./batch-management.html'" class="news-product">
						<i class="iconfont icon-batch-execution"></i>
						<span>批量管理</span>
					</li>
					<li onclick="location.href='./store-deposit.html'" class="new-product">
						<i class="iconfont icon-baoxianchanpin"></i>
						<span>店铺保证</span>
					</li>
				</ul>
			</div>
			<div id="mask">
			</div>
			<div id="is_link">
				<div>
					复制链接成功！请到多艺“<em>广告植入</em>”进行推广!
				</div>
				<button>取消</button>
			</div>
			<div id="is_share">
				<p>分享到</p>
				<div>
					<ul class="row">
						<li>
							<img src="img/weixin.png" alt="">
							<span>微信</span>
						</li>
						<li>
							<img src="img/rengyouquan.png" alt="">
							<span>朋友圈</span>
						</li>
						<li>
							<img src="img/qq.png" alt="">
							<span>QQ好友</span>
						</li>
						<li>
							<img src="img/weibo.png" alt="">
							<span>微薄</span>
						</li>
					</ul>
				</div>
				<button>取消</button>
			</div>
		</div>
		<script src="js/x_rem.js"></script>
		<script src="./js/jquery-1.10.2.js"></script>
		<script src="js/all.js"></script>
		<script type="application/javascript">
			$("#mask").click(function(e) {
				if(e.target !== $("#is_show")) {
					$(this).hide();
					$("#is_show").hide();
				}
			})
			$(function() {
				$(".refer>.popular>.gener>span").click(function() {
					$("#is_link").css("display", "block");
					$("#mask").css("display", "block");
				})
				$("#is_link>button").click(function() {
					$("#is_link").hide();
					$("#mask").hide();
				})
			})
			$(function() {
				$(".refer>.popular>.geners>span").click(function() {
					$("#is_share").css("display", "block");
					$("#mask").css("display", "block");
				})
				$("#is_share>button").click(function() {
					$("#is_share").hide();
					$("#mask").hide();
				})
			})

			// 封装http请求后台
			$(function() {
				var userId = GetQueryString("userId");
				var token = GetQueryString("token");
                if(userId!=null&&token!=null){
                    localStorage.setItem("userId", userId);
                    localStorage.setItem("token", token);
                }else{
                    userId = localStorage.getItem("userId")
                    token = localStorage.getItem("token")
                }
				storeInfo(userId, token);
				shopInfo(0,'solds');
			})

			function storeInfo(userId, token) {
                $.ajax({
                    type: "POST",
                    url: Url + "/app/store/index",
                    contentType: "application/json;charset=utf-8",
                    //    		data : JSON.stringify({
                    //    			"index":1,
                    //    			"size":10,
                    //    			"status":0
                    //    		}),// 你的formid
                    dataType: "json",
                    beforeSend: function(XMLHttpRequest) {
                        XMLHttpRequest.setRequestHeader("token", token);
                        XMLHttpRequest.setRequestHeader("userId", userId);
                    },
                    error: function(request) {
                        alert("Connection error ");
                    },
                    success: function(data) {
                        if(data.message.code == 200) {
                            $("#dianPuName").html(data.data.storeInfo.name); //店铺名字
                            $("#dianPuTuPian").attr("src", data.data.storeInfo.picture); //店铺图片
                            $("#dianPuJianjie").html(data.data.storeInfo.introduce); //店铺简介
                        } else {
                            console.log(data.message.msg)
                            alert(data.message.msg);
                        }
                    }
                });
            }
            function shopInfo(status,spanId) {
			    if(spanId=='solds'){
			        $("#solds").attr("class",'solds');
                    $("#sell").attr("class",'sell');
				}else{
                    $("#solds").attr("class",'sell');
                    $("#sell").attr("class",'solds');
				}
                var userId = localStorage.getItem("userId");
                var token = localStorage.getItem("token");
                $.ajax({
                    type: "POST",
                    url: Url + "/supplier/product/getProductInfo",
                    contentType: "application/json;charset=utf-8",
					data : JSON.stringify({
                        "index":0,
                        "size":10,
                        "status":status
					}),// 你的formid
                    dataType: "json",
                    beforeSend: function(XMLHttpRequest) {
                        XMLHttpRequest.setRequestHeader("token", token);
                        XMLHttpRequest.setRequestHeader("userId", userId);
                    },
                    error: function(request) {
                        alert("Connection error ");
                    },
                    success: function(data) {

                        if(data.message.code == 200) {
                            var html = "";

                            for(var i = 0; i<data.data.productList.length; i++) {
                                html += `
									<div onclick="location.href='./edit-commodity.html?productId=${data.data.productList[i].productId}'" class="introduce row">
										<div class="picture">
											<img src="${data.data.productList[i].picture}" alt="">
										</div>
										<div class="design">
											<p>${data.data.productList[i].title}</p>
											<p>￥${data.data.productList[i].nowPrice}</p>
											<span>总销量 ${data.data.productList[i].saleAmount}</span><span>30日成交额 ${data.data.productList[i].sellCount}</span>
											<span>库存 ${data.data.productList[i].stock}</span><span>添加 2018/08/30</span>
										</div>
										<div class="tag">
											<i class="iconfont icon-youjiantou"></i>
										</div>
									</div>
									<div class="popular">
										<div class="gener">
											<i class="iconfont icon-fenxiang"></i>
											<span>推广</span>
										</div>
										<div class="geners">
											<i class="iconfont icon-icon_share"></i>
											<span>分享</span>
										</div>
									</div>`
                            }
                            $("#shopping-info").html(html);
                        } else {
                            popup(data.message.msg);
                        }
                    }
                });
            }

//			$(function() {
//				var data = JSON.stringify({
//					"index": 0,
//					"size": 10,
//					"status": 0
//				});
//
//				var succrss = (data) => {
//					console.log(data.message.code);
//
//				};
//
//				Hajax("post", "/supplier/product/getProductInfo", data, succrss);
//				//  	optlons
//
//			});
		</script>
	</body>

</html>